//展示隐藏
function showbox() {
    $(".hidebox").show();
    $("#autocomplete").focus();
    $CertusFormAjax.ajax("findSpUserList",{},function (response) {
        var nhlTeams = [];
        var data = response.data;
        for (var i=0;i<data.length;i++){
            var arr={};
            arr.name=data[i].userName+"["+data[i].positonName+"]";
            arr.id = data[i].userId;
            nhlTeams.push(arr);
        }
        //自动补全
        var nhl = $.map(nhlTeams, function (obj) {
            return {
                value: obj.name,
                data: { category: obj.id }
            };
        });
        // Initialize autocomplete with local lookup:
        $('#autocomplete').devbridgeAutocomplete({
            lookup: nhl,
            minChars: 1,
            onSelect: function (suggestion) {
                $("#mgUserId").val(suggestion.data.category);
            },
            showNoSuggestionNotice: true,
            noSuggestionNotice: 'Sorry, no matching results'
        });
    });
};
function hidebox(){
    $(".hidebox").hide();
};
var stepId = $CertusJsonAjax.getStepInstanceId();
var processId = $CertusJsonAjax.getProInstanceId();
$CertusFormAjax.ajax("findLcProblemList",{"processId":processId},function(response){
    var data = response.data;
    $$scope.prbNum = data.prb_num;
    $$scope.rproName = data.rproName;
    $$scope.proName = data.pro_name;
    $$scope.version = data.version;
    $$scope.proStage = data.pro_stage;
    if (data.pro_lv=="3"){
        $$scope.proLv = "高";
    }else if (data.pro_lv=="2"){
        $$scope.proLv = "中";
    }else{
        $$scope.proLv = "低";
    }

    if (data.prb_level=="3"){
        $$scope.prbLevel = "高";
    }else if (data.prb_level=="2"){
        $$scope.prbLevel = "中";
    }else{
        $$scope.prbLevel = "低";
    }
    $$scope.deliverDate = data.deliver_date;
    $$scope.createUser = data.createUser;
    $$scope.createTime = data.createTime;
    $$scope.prbDesc = data.prb_desc;
    $$scope.riskRating = data.risk_rating;
    $$scope.id = data.id;
});
//审核不通过
$(".lcEnd").on('click',function () {
    var id = $("#dmLcId").val();
    $CertusFormAjax.ajax("shutDemanLc",{"stepId":stepId,"id":id},function(response){
        layer.msg("审批成功");
        window.history.back();
    });
});

//转为他人分析
$(".transfer").on('click',function () {
    var tranDesc = $("#tranDesc").val();
    var mgUserId = $("#mgUserId").val();
    var id = $("#prbLcId").val();
    $CertusFormAjax.ajax("toTransferProb",{"id":id,"stepId":stepId,"tranDesc":tranDesc,"mgUserId":mgUserId},function(response){
        layer.msg("提交成功");
        window.history.back();
    });
});
//提交需求小组审批
$(".submit").on('click',function () {
    if (!certusValidateNotnull()){
        return;
    }
    var arr =$("form").serializeArray();
    var data = {};
    for (var i=0;i<arr.length;i++){
        data[arr[i].name] = arr[i].value;
    };
    data.stepId = stepId;
    $CertusFormAjax.ajax("toPrbXqxzSp",{"params":JSON.stringify(data)},function(response){
        layer.msg("提交成功");
        window.history.back();
    });
});

$(".back").on('click',function () {
    var id = $("#prbLcId").val();
    var opinionMsg = $("#opinionMsg").val();
    if (opinionMsg==null||opinionMsg==""){
        alert("请填写审批意见");
        return;
    }
    $CertusFormAjax.ajax("toBackPrbSq",{"id":id,"stepId":stepId,"opinionMsg":opinionMsg},function(response){
        layer.msg("退回成功");
        window.history.back();
    })
})